package com.wwj.utils;

import com.wwj.Constant.Constant;
import com.wwj.pojo.API;
import com.wwj.pojo.Case;

import java.util.ArrayList;
import java.util.List;

public class DataUtils {
    static String  path = Constant.EXCEL_PATH;

    public static List<API> apiList = ExcelUtils.read(path, 0,API.class);
    public static List<Case> caseList = ExcelUtils.read(path, 1,Case.class);

    public static Object[][] getAPIAndByAPIId(String apiId){
        API wantAPI = null;
        ArrayList<Case> wantCases = new ArrayList<>();

        //1.获取wantAPI
        for(API api:apiList){
            //传入的apiId和遍历的apiId相等
            if(apiId.equals(api.getId())){
                wantAPI = api;
                break;
            }
            //
        }

        //获取wantCases
        for(Case c:caseList){
            //传入的apiId和遍历的apiId相等
            if(apiId.equals(c.getApiId())){
                wantCases.add(c);
            }

        }

        Object[][] datas = new Object[wantCases.size()][2];
        for(int i=0;i<wantCases.size();i++){
            datas[i][0] = wantAPI;
            datas[i][1] = wantCases.get(i);

        }
        return datas;



    }
}

